<?php

class User_role extends CI_Model {

    function edit($id_access) {
        $this->db->where('id_access', $id_access);
        $q = $this->db->get('user_access');
        return $q;
    }

    function get_array() {
        $q = $this->db->get('user_access');
        foreach ($q->result_array() as $row) {
            $data{$row['id_access']} = $row['access_name'];
        }
        return $data;
    }

    function access($id_access) {
        $this->db->where('id_access', $id_access);
        $q = $this->db->get('user_access');
        return $q;
    }

    function get_access($id_access) {
        $this->db->where('id_access', $id_access);
        $query = $this->db->get('user_access');

        foreach ($query->result() as $row) {
            $q = $row->access_name;
        }
        return $q;
    }

    function update($id_access, $data) {
        
        $this->db->where('id_access', $id_access);
        $this->db->update('user_access', $data);
        redirect('user_access/index');
    }

    function chek($access, $action) {
        $value = $this->rows($access, $action);
        if ($value == 1) {
            $var = '';
        } else {
            $var = redirect('dashboard/index');
        }
        return $var;
    }

    function rows($access, $action) {
        foreach ($access->result() as $value) {
            $value = $value->$action;
        }
        return $value;
    }

}

?>
